package com.wsx.first.c;

import java.util.Scanner;

/**
 * @author: wangshunxi
 * @date: 2022/5/11 10:17
 * @Description:
 */
public class Main0052 {


    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            while (scanner.hasNext()) {
                String one = scanner.nextLine();
                String two = scanner.nextLine();
                resolve(one, two);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void resolve(String one, String two) {
        int[][] dp = new int[one.length() + 1][two.length() + 1];
        dp[0][0] = 0;
        for (int i = 1; i < dp.length; i++) {
            dp[i][0] = i;
        }
        for (int i = 1; i < dp[0].length; i++) {
            dp[0][i] = i;
        }
        for (int i = 1; i < dp.length; i++) {
            for (int j = 1; j < dp[0].length; j++) {
                if (one.charAt(i - 1) == two.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1];
                } else {
                    dp[i][j] = min(dp[i - 1][j - 1]+1, dp[i][j - 1]+1, dp[i - 1][j]+1);
                }
            }
        }
        System.out.println(dp[one.length()][two.length()]);

    }

    private static int min(int... a) {
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < a.length; i++) {
            min = Math.min(min, a[i]);
        }
        return min;
    }



}
